package com.integrate.rabbitmq.porducer;

import org.springframework.amqp.AmqpException;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessagePostProcessor;

/**
 * @author 刘志强
 * @date 2020/11/24 16:40
 */
public class MyMessagePostProcessor implements MessagePostProcessor {

    private final Long ttl;

    public MyMessagePostProcessor(final Long ttl) {
        this.ttl = ttl;
    }

    @Override
    public Message postProcessMessage(final Message message) throws AmqpException {
        message.getMessageProperties().setExpiration(ttl.toString());
        return message;
    }
}
